package com.atguigu.yygh.cmn.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.atguigu.yygh.cmn.bean.Student;

import java.util.ArrayList;
import java.util.List;

/*==========================================
      时 间:   2022-04-16
      讲 师:   刘  辉
      描 述:   尚硅谷教学团队
 ==========================================*/
public class ExcelWriteDemo {

//    public static void main(String[] args) {
//        List<Student> list=new ArrayList<Student>();
//        list.add(new Student(1,"胡杰",true));
//        list.add(new Student(2,"康师傅",true));
//        list.add(new Student(3,"张亮",true));
//
//        EasyExcel.write("C:\\Users\\LH\\Desktop\\hello.xlsx", Student.class).sheet("学生列表").doWrite(list);
//    }


        public static void main(String[] args) {
        List<Student> list=new ArrayList<Student>();
        list.add(new Student(1,"胡杰",true));
        list.add(new Student(2,"康师傅",true));
        list.add(new Student(3,"张亮",true));

         ExcelWriter excelWriter = EasyExcel.write("C:\\Users\\LH\\Desktop\\hello.xlsx", Student.class).build();
         WriteSheet sheet1 = EasyExcel.writerSheet(0,"列表1").build();
         WriteSheet sheet2 = EasyExcel.writerSheet(1,"列表2").build();
         excelWriter.write(list,sheet1).write(list,sheet2);
         //excelWriter.write(list,sheet2);

         excelWriter.finish();//关闭连接，释放资源
    }

}
